package com.ruoyi.truth.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.truth.domain.QualScoring;
import com.ruoyi.truth.service.IQualScoringService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 定性信息评分Controller
 * 
 * @author ruoyi
 * @date 2023-07-05
 */
@RestController
@RequestMapping("/system/scoring")
public class QualScoringController extends BaseController
{
    @Autowired
    private IQualScoringService qualScoringService;

    /**
     * 查询定性信息评分列表
     */
    @PreAuthorize("@ss.hasPermi('system:scoring:list')")
    @GetMapping("/list")
    public TableDataInfo list(QualScoring qualScoring)
    {
        startPage();
        List<QualScoring> list = qualScoringService.selectQualScoringList(qualScoring);
        return getDataTable(list);
    }

    /**
     * 导出定性信息评分列表
     */
    @PreAuthorize("@ss.hasPermi('system:scoring:export')")
    @Log(title = "定性信息评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QualScoring qualScoring)
    {
        List<QualScoring> list = qualScoringService.selectQualScoringList(qualScoring);
        ExcelUtil<QualScoring> util = new ExcelUtil<QualScoring>(QualScoring.class);
        util.exportExcel(response, list, "定性信息评分数据");
    }

    /**
     * 获取定性信息评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:scoring:query')")
    @GetMapping(value = "/{scoreId}")
    public AjaxResult getInfo(@PathVariable("scoreId") Long scoreId)
    {
        return success(qualScoringService.selectQualScoringByScoreId(scoreId));
    }

    /**
     * 新增定性信息评分
     */
    @PreAuthorize("@ss.hasPermi('system:scoring:add')")
    @Log(title = "定性信息评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QualScoring qualScoring)
    {
        return toAjax(qualScoringService.insertQualScoring(qualScoring));
    }

    /**
     * 修改定性信息评分
     */
    @PreAuthorize("@ss.hasPermi('system:scoring:edit')")
    @Log(title = "定性信息评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QualScoring qualScoring)
    {
        return toAjax(qualScoringService.updateQualScoring(qualScoring));
    }

    /**
     * 删除定性信息评分
     */
    @PreAuthorize("@ss.hasPermi('system:scoring:remove')")
    @Log(title = "定性信息评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scoreIds}")
    public AjaxResult remove(@PathVariable Long[] scoreIds)
    {
        return toAjax(qualScoringService.deleteQualScoringByScoreIds(scoreIds));
    }
}
